package au.com.iglootech.TaxTimeToolTip.ui.log;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import au.com.iglootech.TaxTimeToolTip.Entity.Task;
import au.com.iglootech.TaxTimeToolTip.Entity.TaxTimeSheetLog;
import au.com.iglootech.TaxTimeToolTip.service.TaxTimeSheetLogService;
import au.com.iglootech.TaxTimeToolTip.ui.invoice.InvoiceTaxTab;
import au.com.iglootech.TaxTimeToolTip.util.FeeUtil;
import au.com.iglootech.component.IGTTable;

import com.vaadin.data.util.BeanContainer;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.VerticalLayout;
@Configurable(preConstruction=true)
@Component
@Scope("request")
public class LogPage extends CustomComponent {
	VerticalLayout mainLayout = new VerticalLayout();
	@Autowired
	private transient TaxTimeSheetLogService logService;
	private IGTTable logTabel;  
	private BeanContainer<String, TaxTimeSheetLog> beans;

	public LogPage() {
		setCaption("Log History");
		initContent();
	}

	private void initContent() {
		Panel panel = new Panel("Log");
		beans = new BeanContainer<String, TaxTimeSheetLog>(
				TaxTimeSheetLog.class);
		beans.setBeanIdProperty("key");
		
		List<TaxTimeSheetLog> logs = logService.findAll(null, null);
		for(TaxTimeSheetLog log : logs)
		{
			beans.addBean(log);
		}

		logTabel = new IGTTable("", beans);
		logTabel.setSelectable(true);
		logTabel.setImmediate(true);
		logTabel.setWidth("100%");
		logTabel.setHeight("500px");
		logTabel.setVisibleColumns(new String[]{"time", "eventName", "user"});
		panel.addComponent(logTabel);
		mainLayout.addComponent(panel);
		this.setCompositionRoot(mainLayout);
	}
}